$(document).ready(function() {
	$('#conteudo').hide();
	var noticia;	
	var hash = window.location.hash;
	if (hash !='')
	{
		noticia = $(hash).html();
		$('.abas li a[href="' + hash + '"]').parent().addClass('ativo');		
	} else {
		noticia = $('#conteudo div:first-child').html();			
		$('.abas li:first-child').addClass('ativo');		
	}
	$('#busca').append('<div>' + noticia + '</div>').find('div').slideDown();
	$('.abas li a').click(function(){
		$('.abas li').removeClass('ativo');
		$(this).parent().addClass('ativo');
		var ancora = $(this).attr('href');
		var nome = ancora.substr(1, ancora.length);
		noticia = $('#conteudo div[id="' + nome + '"]').html();
		$('#busca').empty();
		$('#busca').append('<div>' + noticia + '</div>').find('div').slideDown();
	return false();
	});
	
	
	//Busca por cep
	$('.buscaCep').click(function(){
		var url = 'http://cepapi/rest/cep/get';
	    var token = '040215c243d9a611b02e6c6a423e80e6fe59e270';
	    var username = 'thyago';
	    var password = '7c222fb2927d828af22f592134e8932480637c0d';
	    
    
	    function make_base_auth(user, password) {
	    	  var tok = user + ':' + password;
	    	  var hash = btoa(tok);
	    	  return "Basic " + hash;
	    }
	    
	    auth = make_base_auth(username, password);
	      
    	$.ajax
    	  ({
    	    type: "GET",
    	    url: url,
    	    async: false,
    	    data: { cep: "38407339", token: token, PHP_AUTH_USER: username, PHP_AUTH_PW: password },
    	    success: function (ret){
    	        console.log(ret); 
    	    }
    	});
		

	});
	
})